//
//  MySearchTableViewCell.m
//  礼物
//
//  Created by dllo on 15/11/16.
//  Copyright © 2015年 liangsicheng. All rights reserved.
//

#import "MySearchTableViewCell.h"

@implementation MySearchTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}
-(void)createSubViews
{
    self.cover_image_urlImageView=[[UIImageView alloc]initWithFrame:CGRectMake(self.contentView.frame.origin.x, self.contentView.frame.origin.y, self.contentView.frame.size.width/3, 120*HEIGHT/667)];
    [self.contentView addSubview:self.cover_image_urlImageView];
    
    self.descLabel=[[UILabel alloc]init];
    self.descLabel.numberOfLines=0;
    self.descLabel.font=[UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.descLabel];
    self.priceLabel=[[UILabel alloc]initWithFrame:CGRectMake(self.cover_image_urlImageView.frame.origin.x+5*WIDTH/375, self.cover_image_urlImageView.frame.origin.y+self.cover_image_urlImageView.frame.size.height, self.cover_image_urlImageView.frame.size.width-5*WIDTH/375, 30*HEIGHT/667)];
    [self.contentView addSubview:self.priceLabel];
    self.priceLabel.textColor=[UIColor redColor];
    
    self.likes_countLabel=[[UILabel alloc]initWithFrame:CGRectMake(self.contentView.frame.size.width, self.priceLabel.frame.origin.y, 50*WIDTH/375, 30*HEIGHT/667)];
    [self.contentView addSubview:self.likes_countLabel];
    
    self.likebutton=[UIButton buttonWithType:UIButtonTypeCustom];
    self.likebutton.frame=CGRectMake(self.contentView.frame.size.width-20*WIDTH/375, self.priceLabel.frame.origin.y+7*HEIGHT/667, 15*WIDTH/375, 15*HEIGHT/667);
    [self.likebutton setImage:[UIImage imageNamed:@"shouc.png"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.likebutton];
    
    
}
-(void)setModel:(SearchModel *)model
{
    _model=model;
    
    [self.cover_image_urlImageView sd_setImageWithURL:[NSURL URLWithString:_model.cover_image_url] placeholderImage:[UIImage imageNamed:@"beij.png"]];
    self.descLabel.attributedText=self.att;
    CGSize constraint=CGSizeMake(250*WIDTH/375, 120.0f*HEIGHT/667);
    CGSize size=[_model.desc sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:constraint lineBreakMode:NSLineBreakByWordWrapping];
    [self.descLabel setFrame:CGRectMake(self.cover_image_urlImageView.frame.origin.x+self.cover_image_urlImageView.frame.size.width+5*WIDTH/375 , self.cover_image_urlImageView.frame.origin.y+5*HEIGHT/667, (250-50)*WIDTH/375, size.height)];
    self.priceLabel.text=[NSString stringWithFormat:@"￥%@",_model.price];
    self.likes_countLabel.text=[NSString stringWithFormat:@"%ld",_model.likes_count];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
